package com.kingwang.training.designpattern.flyweight;

import com.kingwang.training.designpattern.flyweight.bo.ChessBoardPosition;
import com.kingwang.training.designpattern.flyweight.bo.ChessPieces;
import com.kingwang.training.designpattern.flyweight.bo.ChessPiecesFactory;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Application implements ApplicationRunner {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        ChessPiecesFactory flyweightFactory = new ChessPiecesFactory();

        ChessPieces white = flyweightFactory.getChessPieces("白");
        ChessPieces black = flyweightFactory.getChessPieces("黑");

        white.move(new ChessBoardPosition(5, 3));
        black.move(new ChessBoardPosition(5, 4));

        white.move(new ChessBoardPosition(6, 2));
    }
}
